package com.qxgltj.qxgl.dao;

import java.util.List;

import com.qxgltj.qxgl.model.Modules;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;

/**
 * IModulesDao
 */
public interface IModulesDao extends JpaRepository<Modules,String>,JpaSpecificationExecutor<Modules>{
    //删除子节点
    @Modifying
    @Transactional
    @Query(value = "delete from modules where id=?1",nativeQuery = true)
    int delete (int id);
    //获取用户已经存在的权限
    @Query(value = "SELECT * from modules where id in( SELECT module_id from role_modules where role_id=?1 And parent_id!=0)",nativeQuery = true)
    List<Modules> findAllRoles(int role_id);
}